﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace PRE.Thongke
{
    public partial class FrmThongkeKHtheotrangthaiHD : DevExpress.XtraEditors.XtraForm
    {
        DAL.ThongkeDAL _dal = new DAL.ThongkeDAL();
        public FrmThongkeKHtheotrangthaiHD()
        {
            InitializeComponent();
        }

        private void FrmThongke_Load(object sender, EventArgs e)
        {
            cbotrangthai.Properties.DataSource = _dal.select_trangthai();
            cbotrangthai.ItemIndex = 0;
            string matrth = (cbotrangthai.EditValue + "").Trim();
            DataTable _dtb;
            _dtb = _dal.select_KH_theo_trangthai(matrth);


            if (_dtb != null)
            {
                grcMain.DataSource = _dtb;
            }

            
        }

        private void cbotrangthai_EditValueChanged(object sender, EventArgs e)
        {
            string matrth = (cbotrangthai.EditValue + "").Trim();
            DataTable _dtb;
            _dtb = _dal.select_KH_theo_trangthai(matrth);


            if (_dtb != null)
            {
                grcMain.DataSource = _dtb;
            }
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            var frm = new Report.ReportBase();
            frm.Text = "In: " + Text;
            var rpt = new Report.XRthongkeKHtheotrangthaihopdong();
            string id = (cbotrangthai.EditValue+"").Trim();
            //rpt.parDau.Value = txtDau.Text;
            //rpt.parRot.Value = txtRot.Text;

            rpt.DataSource = _dal.select_KH_theo_trangthai(id);
            frm.SetReport(rpt);
            frm.Show();
            frm.Activate();
        }
    }
}